/*
 * Conformer.cpp
 *
 *  Created on: Jul 6, 2013
 *      Author: x
 */

#include <sstream>
#include "Conformer.h"
#include "Residue.h"

using namespace std;

namespace mcce {

Conformer::Conformer(): iConf(0), hFlag(' '), netcrg(0.0), pKa(0.0), Em(0.0), eTorsion(0.0),
		eVdw0(0.0), eVdw1(0.0), eEpol(0.0), eTors(0.0), eRxn0(0.0), eRxn(0.0), eExtra(0.0),
		eDsolv(0.0), ePh(0.0), eEh(0.0), eMfe(0.0), eSelf0(0.0), eTS(0.0), eSelf(0.0),
		occ(0.0), e(0), H(0), n_atom(0), dummy(false), inRes(0), counter(0)
{}


Conformer::~Conformer() {
}


int Conformer::loadFromHead3(string hLine) {
	// start iConf from 0 !!!
	stringstream(hLine.substr(0, 6)) >> iConf;
	iConf--;
	uniqId = hLine.substr(6, 14);
	hFlag = hLine[21];
	stringstream(hLine.substr(22, 5)) >> occ;
	stringstream(hLine.substr(27, 7)) >> netcrg;
	stringstream(hLine.substr(34, 6)) >> Em;
	stringstream(hLine.substr(40, 6)) >> pKa;
	stringstream(hLine.substr(46, 3)) >> e;
	stringstream(hLine.substr(49, 3)) >> H;
	stringstream(hLine.substr(52, 8)) >> eVdw0;
	stringstream(hLine.substr(60, 8)) >> eVdw1;
	stringstream(hLine.substr(68, 8)) >> eTors;
	stringstream(hLine.substr(76, 8)) >> eEpol;
	stringstream(hLine.substr(84, 8)) >> eDsolv;
	stringstream(hLine.substr(92, 8)) >> eExtra;
	history = hLine.substr(101, 11);

	if (uniqId.substr(3, 2) == "DM") dummy = true;

	return 0;
}

bool Conformer::isBelongToRes(Residue &Res) {

	return (getResName() == Res.getResName());
}

bool Conformer::isSameConfType(const Conformer &conf) const {
	bool sameType = true;

	if (H != conf.getH() || e != conf.getE() || getResName() != conf.getResName() || dummy != conf.isDummy()) {
		sameType = false;
	}

	return sameType;

}

} /* namespace mcce */
